package com.example.homework2.controller;


import com.example.homework2.entity.Student;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpSession;
import java.util.UUID;

@Controller
@RequestMapping("/thymeleaf")
public class ThymeleafController {

    @RequestMapping("/varEL")
    public String varEL(Model model, HttpSession session){
        model.addAttribute(" 1+1 result :",1+1);
        Student student01 = new Student();
        student01.setName("Jenny");
        student01.setPhoneNumber("17639915982");
        model.addAttribute("student01",student01);
        Student student02 = new Student();
        student02.setName("Peter");
        student02.setAddress("河南财经政法大学");
        session.setAttribute("student02",student02);
        return "varEL";
    }

    @RequestMapping("/urlEL")
    public String varEL(){
        return "url_el";
    }

    @RequestMapping("/toIndex")
    public String toIndex(){
        return "index";
    }

    @RequestMapping("/literal")
    public String literal(Model model){
        Student student = new Student();
        student.setSid(UUID.randomUUID().toString());
        model.addAttribute("student",student);
        return "literal";
    }

    @RequestMapping("/calculate")
    public String calculate(int param01,int param02, Model model){
        model.addAttribute("a",param01);
        model.addAttribute("b",param02);
        model.addAttribute("c",2);
        Student student = new Student();
        student.setSid(UUID.randomUUID().toString());
        model.addAttribute("student",student);

        return "calculate";
    }


}
